<html>
<head><meta charset="utf-8"><title>Musing on intrinsics with MIR available · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html">Musing on intrinsics with MIR available</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="243689025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Musing%20on%20intrinsics%20with%20MIR%20available/near/243689025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html#243689025">(Jun 23 2021 at 17:56)</a>:</h4>
<p>Splitting this off from the cg_gcc thread...</p>
<p>Right now we do</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">extern</span><span class="w"> </span><span class="s">"rust-intrinsic"</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">ctlz_nonzero</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Copy</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Would it be plausible to instead do something like this?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">extern</span><span class="w"> </span><span class="s">"rust-intrinsic"</span><span class="w"> </span><span class="k">fn</span> <span class="nf">ctlz_nonzero</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Copy</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="n">ctlz</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>With the backend then being able to use that implementation of the intrinsic if they don't override it?</p>
<p>(If this conversation was already exhausted related to the simd stuff, sorry.)</p>



<a name="243689710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Musing%20on%20intrinsics%20with%20MIR%20available/near/243689710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html#243689710">(Jun 23 2021 at 18:01)</a>:</h4>
<p>It'd be nice to be able to inline the definitions of the fallbacks, yeah.</p>



<a name="243689742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Musing%20on%20intrinsics%20with%20MIR%20available/near/243689742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html#243689742">(Jun 23 2021 at 18:01)</a>:</h4>
<p>(And write those fallbacks in Rust rather than in MIR.)</p>



<a name="243689842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Musing%20on%20intrinsics%20with%20MIR%20available/near/243689842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html#243689842">(Jun 23 2021 at 18:02)</a>:</h4>
<p>Many of these are provided by compiler-builtins</p>



<a name="243719813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Musing%20on%20intrinsics%20with%20MIR%20available/near/243719813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html#243719813">(Jun 23 2021 at 22:13)</a>:</h4>
<p>yes, this is something we'd really like, and not just for these intrinsics, but especially for SIMD intrinsics</p>



<a name="243722800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Musing%20on%20intrinsics%20with%20MIR%20available/near/243722800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Musing.20on.20intrinsics.20with.20MIR.20available.html#243722800">(Jun 23 2021 at 22:50)</a>:</h4>
<p>Reminds me of <a href="#narrow/stream/131828-t-compiler/topic/reifying.20function.20ptrs.20for.20intrinsics.20.2384297">https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/reifying.20function.20ptrs.20for.20intrinsics.20.2384297</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>